package com.alianlab.zhouzhang.repository;

import com.alianlab.zhouzhang.domain.Author;
import com.alianlab.zhouzhang.domain.BookBasic;
import com.alianlab.zhouzhang.domain.BookType;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import org.springframework.data.jpa.repository.*;


/**
 * Spring Data JPA repository for the BookBasic entity.
 */
@SuppressWarnings("unused")
@Repository
public interface BookBasicRepository extends JpaRepository<BookBasic, Long> {

    @Query("SELECT a FROM BookBasic a\n" +
        "WHERE ( a.author LIKE CONCAT('%',?1,'%')or a.bookName LIKE CONCAT('%',?1,'%'))  ORDER BY a.bookName ")
    Page<BookBasic> findBookBasicLike(String keyword , Pageable pageable);

    Page<BookBasic> findBookBasicsByBookTypeIdOrderByIdDesc(BookType bookType, Pageable pageable);

    Page<BookBasic> findBookBasicsByAuthodIdOrderByIdAsc(Author author, Pageable pageable);

}
